#import "RNHistoryItem.h"
#import "NSManagedObject+SRAdditions.h"
#import "RNItem.h"
#import "RNFavorites.h"

@implementation RNHistoryItem 

@dynamic tags;
@dynamic count;
@dynamic notes;
@dynamic loggedDate;
@dynamic item;

+(NSSet *)keys {
    return [NSSet setWithObjects:@"title", @"loggedDate", nil];
}

+(NSSet *)keyPathsForValuesAffectingObjectDictionary {
    return [self keys];
}

-(NSDictionary *)objectDictionary {
    return [self dictionaryWithValuesForKeys:[[RNHistoryItem keys] allObjects]];
}

-(NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *dictionaryRepresentation = [NSMutableDictionary dictionary];
    [dictionaryRepresentation setValue:[self count] forKey:@"count"];
    [dictionaryRepresentation setValue:[self notes] forKey:@"notes"];
    [dictionaryRepresentation setValue:[self tags] forKey:@"tags"];
    [dictionaryRepresentation setValue:[[self item] URIRepresentation] forKey:@"item"];
    return dictionaryRepresentation;
}

-(NSString *)title {
    return [[self item] title];
}

-(void)moveToContainer:(NSManagedObject *)container {
    if ([container isKindOfClass:[RNFavorites class]]) {
        [[self item] setFavorite:[NSNumber numberWithBool:YES]];
    }
}

-(NSArray *)children {
    return nil;
}

-(NSUInteger)displayIndex {
    return 0;
}

@end
